#ifndef BUILDING_H
#define BUILDING_H

#include "GameObject.h"

struct Triangle
{
	Triangle(){}
	Triangle(D3DXVECTOR3 x,D3DXVECTOR3 y,D3DXVECTOR3 z)
	{
		a=x;b=y;c=z;
		ab=b-a;
		ba=a-b;
		bc=c-b;
		cb=b-c;
		ca=a-c;
		ac=c-a;

		D3DXVec3Normalize(&NormAB,&ab);
		D3DXVec3Normalize(&NormBA,&ba);
		D3DXVec3Normalize(&NormBC,&bc);
		D3DXVec3Normalize(&NormCB,&cb);
		D3DXVec3Normalize(&NormCA,&ca);
		D3DXVec3Normalize(&NormAC,&ac);
		AngleA= acos(D3DXVec3Dot(&NormAB,&NormAC));
		AngleB= acos(D3DXVec3Dot(&NormBA,&NormBC));
		AngleC= acos(D3DXVec3Dot(&NormCA,&NormCB));
	}
	D3DXVECTOR3 a,b,c,ab,ba,bc,cb,ca,ac,NormAB,NormBA,NormBC,NormCB,NormCA,NormAC;
	float AngleA,AngleB,AngleC;
};

enum TriTypes
{
	PYRAMID,
	CORNER,
	TRIROUND
};

enum SquareTypes
{
	SIMPLE,
	BLOCKY,
	MODERN,
	CLASSIC
};

class Building : public GameObject
{
public:
	void Generate(D3DXVECTOR3 centre, D3DXVECTOR3 area);
	void Generate(D3DXVECTOR3 offset, Triangle area, float MaxHeight);
	void Generate(D3DXVECTOR3 centre, D3DXVECTOR3* corners, float heigh);
	void GenBlocky();
	void GenModern();
	void GenClassic();
	void GenSimple();
	void GenCorner();
	void GenPyramid();
	void GenRoundedTri();
	void NextStep();
private:
	D3DXVECTOR3 m_vArea;
	D3DXVECTOR3 m_vCentroid;
	Triangle m_vTriArea;
	int m_Step;
	int m_MaxStep;
	bool m_Stepped;
	int m_Type;
	float m_LastTierHeight;
	int m_Height;
	float m_maxLeft,m_maxRight,m_maxFront,m_maxBack;
	
};
#endif